home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0011_Very Large Graphic Image.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  2KB  |  49 lines

  1. {
  2. WILBERT VAN LEIJEN
  3.  
  4. > I am looking for a way to get an Image into a pointer (besides arrays)
  5. > and write it to my disk. I am using arrays right now, and works fine, but
  6. > When  I get big images I run out of mem fast...  :: IBUF : array [1..30000]
  7. > of byte; getimage(x1,y1,x2,y2,IBUF); repeat Write(f,IBUF[NUM]); num:=num+1;
  8. > until num=sizeof(ibuf);
  9. > This works as long as I dont try to grab a large image.
  10.  
  11. These "large images" are in fact stored in "planes", chunks of up to 64 kByte
  12. in size. You must understand the VGA architecture to store these in a file.
  13. The only VGA video mode that keeps all data (from the programmer's point of
  14. view) into a single data space is mode 13h (320x200 with 256 colours): a simple
  15. array [1..200, 1..320] of Byte.  The other video modes require you to access
  16. the VGA hardware: take for example 640x480 by 16 colours: 4 planes of 38,400
  17. bytes (Red, Green, Blue and Intensity).  Together with the colour information
  18. as returned by BIOS call INT 10h/AX=1012h they make up the picture.
  19.  
  20. Here's how you select a plane:
  21. }
  22.  
  23. Procedure SwitchBitplane(plane : Byte); Assembler;
  24.  
  25. ASM
  26.   MOV   DX, 3C4h
  27.   MOV   AL, 2
  28.   OUT   DX, AL
  29.   INC   DX
  30.   MOV   AL, plane
  31.   OUT   DX, AL
  32. end;
  33.  
  34. {
  35. Assume the video mode to be 12h (640x480/16 colours), BitplaneSize = 38400, and
  36. Bitplane is an Array[0..3] of pointer to an array [1..38400] of Byte:
  37. }
  38.       For i := 0 to 3 Do
  39.         Begin
  40.           SwitchBitplane(1 shl i);
  41.           Move(Bitplane[i]^, Ptr($A000, $0000)^, BitplaneSize);
  42.         end;
  43. {
  44. This is a snippet of code lifted from my VGAGRAB package; a TSR that dumps
  45. graphic information (any standard VGA mode) to a disk file by pressing
  46. <PrtScr>, plus a few demo programs written in TP - with source code.  Available
  47. on FTP sites.
  48. }
  49.